package com.holly.unit.system.modular.notice.wrapper;

import cn.hutool.extra.spring.SpringUtil;
import com.holly.unit.system.api.UserServiceApi;
import com.holly.unit.system.api.pojo.user.SysUserDTO;
import com.holly.unit.system.modular.notice.entity.SysNotice;
import com.holly.unit.wrapper.api.BaseWrapper;

import java.util.HashMap;
import java.util.Map;

/**
 * 系统通知的包装
 *
 * @author holly
 * @date 2021/6/14 17:28
 */
public class NoticeWrapper implements BaseWrapper<SysNotice> {

    @Override
    public Map<String, Object> doWrap(SysNotice beWrappedModel) {

        HashMap<String, Object> resultMap = new HashMap<>();
        UserServiceApi userServiceApi = SpringUtil.getBean(UserServiceApi.class);

        if (beWrappedModel.getCreateUser() != null) {
            SysUserDTO sysUserDTO = userServiceApi.getUserInfoByUserId(beWrappedModel.getCreateUser());
            if (sysUserDTO != null) {
                resultMap.put("createUserName", sysUserDTO.getRealName());
            }
        }

        return resultMap;
    }

}
